/**
 * Created by 2015302580057 on 2017/7/12.
 */
function register() {
    $.ajax({
            url: '/Register',
            type: "POST",
            data: {
                username: $("#username").val(),
                password:hex_md5($("#password").val()),
                myemail:$("#myemail").val(),
                action: "register"
            }
            ,
            success: function (data) {
                switch (data['code']){
                    case 0:
                        window.location.href = "/giggleLogin.html";
                        break;
                    case 1:
                        alert("用户已存在！");
                        break;
                    case 2:
                        alert("不可思议的事情发生了");
                        break;
                }
            }
            ,
            error: function (err) {
                console.log(err);
            }
        }
    );
}

function showEmailMessage() {

    var testEmail = $("#myemail").val();
    var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
    if (!reg.exec(testEmail)){
        $("#emailMessage").css("display","block");
    }

}